package com.hyx.api.controller.pc_admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.hyx.api.domain.bo.WalletChangeInfoBo;
import com.hyx.api.domain.vo.WalletChangeInfoVo;
import com.hyx.api.service.pc_admin.IWalletChangeInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 钱包收支Controller
 *
 * @author HK
 * @date 2023-10-26
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/info")
public class WalletChangeInfoController extends BaseController
{
    private final IWalletChangeInfoService walletChangeInfoService;

    /**
     * 查询钱包收支列表
     */
    @PreAuthorize("@ss.hasPermi('api:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(WalletChangeInfoBo bo)
    {
        startPage();
        List<WalletChangeInfoVo> list = walletChangeInfoService.selectWalletChangeInfoList(bo);
        return getDataTable(list);
    }

    /**
     * 导出钱包收支列表
     */
    @PreAuthorize("@ss.hasPermi('api:info:export')")
    @Log(title = "钱包收支", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WalletChangeInfoBo bo)
    {
        List<WalletChangeInfoVo> list = walletChangeInfoService.selectWalletChangeInfoList(bo);
        ExcelUtil<WalletChangeInfoVo> util = new ExcelUtil<>(WalletChangeInfoVo.class);
        util.exportExcel(response, list, "钱包收支数据");
    }


    @PreAuthorize("@ss.hasPermi('api:info:add')")
    @Log(title = "钱包充值", businessType = BusinessType.EXPORT)
    @PostMapping("/recharge")
    public AjaxResult recharge(@Validated @RequestBody WalletChangeInfoBo bo) {
        return toAjax(walletChangeInfoService.recharge(bo));
    }

}
